package com.xdb.sqlparser.ast.statement;

import java.util.ArrayList;
import java.util.List;

import com.xdb.sqlparser.ast.SQLName;
import com.xdb.sqlparser.ast.AbstractSQLStatementImpl;
import com.xdb.sqlparser.visitor.SQLAstVisitor;
/**
 * 标示TRUNCATE TABLE语句
 * @author woate
 *
 */
public class SQLTruncateStatement extends AbstractSQLStatementImpl {
	/**
	 * 清空的表列表
	 */
	protected List<SQLExprTableSource> tableSources = new ArrayList<SQLExprTableSource>(2);

	private boolean purgeSnapshotLog = false;

	private boolean only;
	private Boolean restartIdentity;
	/**
	 * 级联清空
	 */
	private Boolean cascade;

	public SQLTruncateStatement() {

	}

	public SQLTruncateStatement(String dbType) {
		super(dbType);
	}
	/**
	 * 清空的表列表
	 * @return
	 */
	public List<SQLExprTableSource> getTableSources() {
		return tableSources;
	}
	/**
	 * 清空的表列表
	 * @param tableSources
	 */
	public void setTableSources(List<SQLExprTableSource> tableSources) {
		this.tableSources = tableSources;
	}
	/**
	 * 增加一个表
	 * @param name
	 */
	public void addTableSource(SQLName name) {
		SQLExprTableSource tableSource = new SQLExprTableSource(name);
		tableSource.setParent(this);
		this.tableSources.add(tableSource);
	}

	@Override
	protected void accept0(SQLAstVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, tableSources);
		}
		visitor.endVisit(this);
	}

	public boolean isPurgeSnapshotLog() {
		return purgeSnapshotLog;
	}

	public void setPurgeSnapshotLog(boolean purgeSnapshotLog) {
		this.purgeSnapshotLog = purgeSnapshotLog;
	}

	public boolean isOnly() {
		return only;
	}

	public void setOnly(boolean only) {
		this.only = only;
	}

	public Boolean getRestartIdentity() {
		return restartIdentity;
	}

	public void setRestartIdentity(Boolean restartIdentity) {
		this.restartIdentity = restartIdentity;
	}

	public Boolean getCascade() {
		return cascade;
	}

	public void setCascade(Boolean cascade) {
		this.cascade = cascade;
	}
}
